/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package foxmob.mlts.view.marker;

import foxmob.mlts.model.Question;

/**
 *
 * @author Lunayo
 */
public class AssessmentPanel extends javax.swing.JPanel {

    /**
     * Creates new form AssessmentPanel
     */
    public AssessmentPanel() {
        initComponents();
    }
    
    public void setNumberLabel(int number) {
        String numberText = Integer.toString(number);
        this.numberLabel.setText(numberText);
    }
    
    
    public void setDelegate(MarkAnswerDetailPanel delegate) {
        this.delegate = delegate;
    }
    
    public void setIsCorrect(boolean isCorrect) {
        if (isCorrect) {
            this.correctRadioButton.setSelected(true);
        } else {
            this.wrongRadioButton.setSelected(true);
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        assesmentButtonGroup = new javax.swing.ButtonGroup();
        numberLabel = new javax.swing.JLabel();
        correctRadioButton = new javax.swing.JRadioButton();
        wrongRadioButton = new javax.swing.JRadioButton();

        numberLabel.setText("Number");

        assesmentButtonGroup.add(correctRadioButton);
        correctRadioButton.setText("Correct");
        correctRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                correctRadioButtonActionPerformed(evt);
            }
        });

        assesmentButtonGroup.add(wrongRadioButton);
        wrongRadioButton.setText("Wrong");
        wrongRadioButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                wrongRadioButtonActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(numberLabel)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(correctRadioButton)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(wrongRadioButton)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                .add(numberLabel)
                .add(correctRadioButton)
                .add(wrongRadioButton))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void correctRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_correctRadioButtonActionPerformed
        // TODO add your handling code here:
        int number = Integer.parseInt(numberLabel.getText());
        try {
            delegate.correctRadioButtonDidTap(number);
        } catch (Exception e) {
            System.err.print("Error : Method was not found. " + e.getMessage());
        }
    }//GEN-LAST:event_correctRadioButtonActionPerformed

    private void wrongRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_wrongRadioButtonActionPerformed
        // TODO add your handling code here:
        int number = Integer.parseInt(numberLabel.getText());
        try {
            delegate.wrongRadioButtonDidTap(number);
        } catch (Exception e) {
            System.err.print("Error : Method was not found. " + e.getMessage());
        }
    }//GEN-LAST:event_wrongRadioButtonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup assesmentButtonGroup;
    private javax.swing.JRadioButton correctRadioButton;
    private javax.swing.JLabel numberLabel;
    private javax.swing.JRadioButton wrongRadioButton;
    // End of variables declaration//GEN-END:variables

    private MarkAnswerDetailPanel delegate;
}
